package com.njzxw.fs.serversys.server;

import com.njzxw.fs.commonutil.bean.BaseBean;
import com.njzxw.fs.commonutil.util.ExcelUtils;
import com.njzxw.fs.commonutil.util.SignUtil;
import com.njzxw.fs.commonutil.util.StringHelper;
import com.njzxw.fs.commonutil.util.Validator;
import com.njzxw.fs.commonutil.util.aes.XyBizMsgCrypt;
import com.njzxw.fs.commonutil.web.BaseServer;
import com.njzxw.fs.commonutil.web.ReturnMap;
import com.njzxw.fs.serversys.bean.OrgBean;
import com.njzxw.fs.serversys.bean.UserBean;
import com.njzxw.fs.serversys.repository.OrgReq;
import com.njzxw.fs.serversys.repository.UserReq;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;

@Service
public class UserServer extends BaseServer{

    @Autowired
    private UserReq userReq;

    @Autowired
    private OrgReq orgReq;

    public ReturnMap getList(HttpServletRequest request, HttpServletResponse response, UserBean userBean) {
        if(!StringUtils.isBlank(userBean.getName())){
            userBean.setName("%"+userBean.getName()+"%");
        }
        if(!StringUtils.isBlank(userBean.getMobile())){
            userBean.setMobile("%"+userBean.getMobile()+"%");
        }
        if(!StringUtils.isBlank(userBean.getEmail())){
            userBean.setEmail("%"+userBean.getEmail()+"%");
        }

        returnMap.setPageData(userReq.getListPageManageOrg(userBean));
        return returnMap.getSucceeReturnMap();
    }

    public ReturnMap getMap(HttpServletRequest request, HttpServletResponse response, UserBean userBean) {
        returnMap.setDataMaps(userReq.getMap(userBean));
        return returnMap.getSucceeReturnMap();
    }

    @Transactional
    public ReturnMap save(HttpServletRequest request, HttpServletResponse response, UserBean userBean) {

        if(StringUtils.isBlank(userBean.getId())){
            if(userReq.insertUser(userBean) != 1){
                return returnMap.getErrorReturnMap("操作用户失败");
            }

            //设置初始密码
            userBean.setPassword(SignUtil.getMD5("12345678"));

        }else{
            if(userReq.updateUser(userBean) != 1){
                return returnMap.getErrorReturnMap("操作用户失败");
            }
        }

        if(userReq.deleteUserOrg(userBean) < 0){
            return returnMap.getErrorReturnMap("操作用户去除组织关系失败");
        }

        if(userReq.deleteUserRule(userBean) < 0){
            return returnMap.getErrorReturnMap("操作用户去除角色关系失败");
        }

        if(userBean.getOrg_ids() != null){
            for(int i=0;i<userBean.getOrg_ids().length;i++){
                UserBean userBeanOrg = new UserBean();
                userBeanOrg.setId(userBean.getId());
                userBeanOrg.setOrg_id(userBean.getOrg_ids()[i]);

                if(userReq.insertUserOrg(userBeanOrg) < 0){
                    return returnMap.getErrorReturnMap("操作用户新增组织关系失败");
                }

            }
        }

        if(userBean.getRole_ids() != null){
            for(int i=0;i<userBean.getRole_ids().length;i++){
                UserBean userBeanRule = new UserBean();
                userBeanRule.setId(userBean.getId());
                userBeanRule.setRole_id(userBean.getRole_ids()[i]);

                if(userReq.insertUserRole(userBeanRule) < 0){
                    return returnMap.getErrorReturnMap("操作用户新增角色关系失败");
                }

            }
        }

        return returnMap.getSucceeReturnMap();

    }

    @Transactional
    public ReturnMap delete(HttpServletRequest request, HttpServletResponse response, UserBean userBean) {

        if(userBean.getIds() != null){
            for(int i=0;i<userBean.getIds().size();i++){
                userBean.setId(userBean.getIds().get(i));
                if(userReq.deleteUser(userBean) != 1){
                    return returnMap.getErrorReturnMap("删除用户失败");
                }

                if(userReq.deleteUserRule(userBean) < 0){
                    return returnMap.getErrorReturnMap("删除用户对应角色失败");
                }

                if(userReq.deleteUserOrg(userBean)  < 0){
                    return returnMap.getErrorReturnMap("删除用户对应组织失败");
                }
            }
        }else{
            return returnMap.getErrorReturnMap("未查询到需要删除的数据");
        }

        return returnMap.getSucceeReturnMap();
    }

    public ReturnMap resetPassword(HttpServletRequest request, HttpServletResponse response, UserBean userBean) {
        if(userBean.getIds() != null) {
            for (int i = 0; i < userBean.getIds().size(); i++) {
                userBean.setId(userBean.getIds().get(i));
                userBean.setPassword(SignUtil.getMD5("12345678"));
                if (userReq.resetPassword(userBean) != 1) {
                    return returnMap.getErrorReturnMap("密码重置失败");
                }
            }
        }else{
            return returnMap.getErrorReturnMap("未查询到需要重置密码的数据");
        }
        return returnMap.getSucceeReturnMap();
    }

    /**
     * 登录
     * @param request
     * @param response
     * @param userBean
     * @return
     */
    public ReturnMap login(HttpServletRequest request, HttpServletResponse response, UserBean userBean) {
        userBean.setEmail(userBean.getMobile());

        String code = redisUtil.getValue(userBean.getUuid(),String.class);

        logger.debug(userBean.getUuid()+"coderedis:"+redisUtil.getValue(userBean.getUuid(),String.class));

        if(code == null){
            returnMap.setMsgMaps("验证码已失效，请重新输入");
            returnMap.setReturnMaps(ReturnMap.States.ERROR2);
            return returnMap;
        }

        if(!code.toLowerCase().equals(userBean.getVercode().toLowerCase())){
            logger.debug(userBean.getVercode()+"=="+code);
            return returnMap.getErrorReturnMap("验证码输入错误");
        }

        Integer state = userReq.getUserState(userBean);
        if(state == null){
            return returnMap.getErrorReturnMap("用户名或密码输入错误");
        }else if(state == 1){

            //检查是否不存在有效的商户信息，如果

            redisUtil.deleteKey(userBean.getUuid());

            String token = UUID.randomUUID().toString();

            Map<String,Object> map = userReq.getMapPass(userBean);

            List<Map<String,Object>> menuUrlList = userReq.getUserMenuUrl(userBean);

            map.put("menuUrlList",menuUrlList == null?new ArrayList<Map<String,Object>>():menuUrlList);

            //获取部门管理员下级所有组织下级
            userBean.setId(StringHelper.get(map,"id"));
            map.put("manageOrg",userReq.getManageOrg(userBean));
//            map.put("merchant_id",userReq.getMerchantId(StringHelper.get(map,"id"),common.getSystem("MERCHANT.ORG.TIER")));

            redisUtil.setKey(token, JSONObject.fromObject(map).toString(),Long.valueOf(common.getSystem("LOGIN.OUT.TIME")), TimeUnit.MINUTES);

            returnMap.setReturnMap("control",getQx(menuUrlList));
            returnMap.setReturnMap("token",token);
            returnMap.setReturnMap("id", StringHelper.get(map,"id"));
            returnMap.setReturnMap("name", StringHelper.get(map,"name"));
            returnMap.setReturnMap("head_img", StringHelper.get(map,"head_img"));

            return returnMap.getSucceeReturnMap();
        }else if(state == 0){
            return returnMap.getErrorReturnMap("您被管理员限制禁止登录");
        }else if(state == 2){
            return returnMap.getErrorReturnMap("您已离职，无法登录系统");
        }

        return returnMap.getErrorReturnMap("您的账户异常，暂不可登录。");

    }

    /**
     * 获取商户ID与店铺ID
     *
     * @param id
     * @return
     */
    public BaseBean getMerchantShop(String id){
        BaseBean baseBean = new BaseBean();
        String merchant_org_tier = common.getSystem("MERCHANT.ORG.TIER");//获取商户所在层级



        return baseBean;
    }

    /**
     * 判断是否是平台人员
     * @return
     */
    public boolean checkTerrace(String id){

        return false;
    }


    /**
     * 获取md5加密后的权限url
     * @param menuUrlList
     * @return
     */
    public List<String> getQx(List<Map<String,Object>> menuUrlList){
        List<String> quanxian = new ArrayList<>();
        if(menuUrlList != null && !menuUrlList.isEmpty()){
            int cnt = menuUrlList.size();
            for(int i=0;i< cnt;i++){
                String urlmd5 = StringHelper.get(menuUrlList.get(i),"urlmd5");
                quanxian.add(urlmd5);
            }
        }
        return quanxian;
    }

    public ReturnMap forbidden(HttpServletRequest request, HttpServletResponse response, UserBean userBean) {

        if(userBean.getIds() != null) {
            for(int i=0;i<userBean.getIds().size();i++) {
                userBean.setId(userBean.getIds().get(i));
                if (userReq.forbidden(userBean) != 1) {
                    return returnMap.getErrorReturnMap("禁用或禁用失败");
                }
            }
        }else{
            return returnMap.getErrorReturnMap("未查询到需要禁用或禁用的数据");
        }
        return returnMap.getSucceeReturnMap();

    }

    public ReturnMap loginOut(HttpServletRequest request, HttpServletResponse response, UserBean userBean) {

        return returnMap.getSucceeReturnMap();
    }

    /**
     * 加载组织跟角色信息
     * @param request
     * @param response
     * @return
     */
    public ReturnMap loadRoleOrg(HttpServletRequest request,
                                 HttpServletResponse response,UserBean userBean) {
        //查询组织信息
        returnMap.setReturnMap("org", orgReq.getOrgList(new OrgBean()));
        //查询角色信息
        returnMap.setReturnMap("role", userReq.getRoleList());

        if(!StringUtils.isBlank(userBean.getId())){
            returnMap.setReturnMap("user", userReq.getMap(userBean));
        }

        return returnMap.getSucceeReturnMaps();
    }

    @Transactional
    public ReturnMap saveUser(HttpServletRequest request, HttpServletResponse response,UserBean userBean) {

        //进行图片处理 新上传
        if(!StringUtils.isBlank(userBean.getHeadimg())){
            String imgId = ossUtil.exeFile(userBean.getHeadimg(),"/user/");
            logger.debug("imgID:"+imgId);
            if(StringUtils.isBlank(imgId)){
                return returnMap.getErrorReturnMap("圖片處理失敗");
            }
            userBean.setHeadimg(imgId);
        }else if(!StringUtils.isBlank(userBean.getHeadid())){
            userBean.setHeadimg(userBean.getHeadid());
        }

        if(userReq.checkUserMobile(userBean) != 0){
            return returnMap.getErrorReturnMap("手机号已被使用");
        }

        if(userReq.checkUserEmail(userBean) != 0 ){
            return returnMap.getErrorReturnMap("email已被使用");
        }

        if("".equals(userBean.getId())||userBean.getId() == null){//新增操作
            try {
                userBean.setPassword(XyBizMsgCrypt.MD5("12345678"));
            } catch (Exception e) {
                logger.error("新增用户加密出错：",e);
                return returnMap.getErrorReturnMap("新增失败，请稍后再试");
            }
            if(userReq.insertUser(userBean) != 1){
                return returnMap.getErrorReturnMap("新增失败，请稍后再试");
            }
        }else{//更新更新用户信息
            if(!StringUtils.isBlank(userBean.getOrgStr())) {
                //先删除用户组织信息
                if (userReq.deleteUserOrg(userBean) < 0) {
                    return returnMap.getErrorReturnMap("新增失败，请稍后再试");
                }
            }

            if(!StringUtils.isBlank(userBean.getOrgManagerStr())) {
                //先删除用户组织信息
                if (userReq.deleteUserOrgManager(userBean) < 0) {
                    return returnMap.getErrorReturnMap("新增失败，请稍后再试");
                }
            }

            if(!StringUtils.isBlank(userBean.getRoleStr())) {
                //删除用户角色信息
                if (userReq.deleteUserRule(userBean) < 0) {
                    return returnMap.getErrorReturnMap("新增失败，请稍后再试");
                }
            }

            if(userReq.updateUser(userBean) != 1){
                return returnMap.getErrorReturnMap("新增失败，请稍后再试");
            }
        }

        //进行插入用户组织信息
        if(!StringUtils.isBlank(userBean.getOrgStr())){
            String[] orgs = userBean.getOrgStr().split(",");
            for(int i=0;i<orgs.length;i++){
                if(!orgs[i].trim().equals("")){
                    UserBean userBean1 = new UserBean();
                    userBean1.setId(userBean.getId());
                    userBean1.setOrg_id(orgs[i]);
                    if(userReq.insertUserOrg(userBean1) != 1){
                        return returnMap.getErrorReturnMap("新增失败，请稍后再试");
                    }
                }
            }
        }

        //进行插入部门管理员角色
        if(!StringUtils.isBlank(userBean.getOrgManagerStr())){
            String[] orgs = userBean.getOrgManagerStr().split(",");
            for(int i=0;i<orgs.length;i++){
                if(!orgs[i].trim().equals("")){
                    UserBean userBean1 = new UserBean();
                    userBean1.setId(userBean.getId());
                    userBean1.setOrg_id(orgs[i]);
                    if(userReq.insertUserOrgManager(userBean1) != 1){
                        return returnMap.getErrorReturnMap("新增失败，请稍后再试");
                    }
                }
            }
        }

        if(!StringUtils.isBlank(userBean.getRoleStr())){
            //进行插入用户角色信息
            String[] roles = userBean.getRoleStr().split(",");
            for(int i=0;i<roles.length;i++){
                if(!roles[i].trim().equals("")){
                    UserBean userBean1 = new UserBean();
                    userBean1.setId(userBean.getId());
                    userBean1.setRole_id(roles[i]);
                    if(userReq.insertUserRole(userBean1) != 1){
                        return returnMap.getErrorReturnMap("新增失败，请稍后再试");
                    }
                }
            }
        }

        return returnMap.getSucceeReturnMaps();
    }

    public void getCode(HttpServletRequest request, HttpServletResponse response) {
        try {
            String width = req.getAjaxValue(request, "w");
            String height = req.getAjaxValue(request, "h");
            String codeLength = req.getAjaxValue(request, "l");
            String uuid = req.getAjaxValue(request, "UUID");
            String type = req.getAjaxValue(request, "type");//1登录
            if (!validator.isInteger(width)) {
                width = "76";
            }
            if (!validator.isInteger(height)) {
                height = "38";
            }
            if (!validator.isInteger(codeLength)) {
                codeLength = "4";
            }

            String code = verifyCodeUtils.generateVerifyCode(Integer.valueOf(codeLength));
            logger.debug("生成的验证码12：" + code + "--" + width + "---" + height+"---"+redisUtil.getValue(uuid,String.class));

            redisUtil.setKey(uuid,code,5L, TimeUnit.MINUTES);

            logger.debug(uuid+"coderedis:"+redisUtil.getValue(uuid,String.class));

            verifyCodeUtils.outputImage(Integer.valueOf(width), Integer.valueOf(height), response, code);

        } catch (IOException e) {
            logger.error("验证码生成出错：", e);
        }

    }

    public ReturnMap importUser(HttpServletRequest request, HttpServletResponse response,BaseBean baseBean) {
        String fileDir = "/user/import/";//文件下载到那个目录
        String importTable = "t_manager_user";//主要插入表的名称

        /**
         * 验证基本读取数据
         */
        List<Map<String,String>> verifyList = new ArrayList<>();
        Map<String,String> map = new HashMap<>();
        map.put("col","col0");
        map.put("regex", Validator.REGEX_NOT_EMPTY);
        map.put("msg","用户名不能为空");
        verifyList.add(map);

        Map<String,String> map1 = new HashMap<>();
        map1.put("col","col1");
        map1.put("regex", Validator.REGEX_EMAIL);
        map1.put("msg","email号格式不符合");
        verifyList.add(map1);

        Map<String,String> map2 = new HashMap<>();
        map2.put("col","col2");
        map2.put("regex", Validator.REGEX_MOBILE);
        map2.put("msg","手机号格式不符合");
        verifyList.add(map2);

        Map<String,String> map3 = new HashMap<>();
        map3.put("col","col3");
        map3.put("regex", Validator.YEAR_MONTH_DAY);
        map3.put("msg","生日格式不符合要求，只能是如2018-02-03");
        verifyList.add(map3);

        /**
         * 校验sql语句
         */
        List<String> verifySql = new ArrayList<>();
        verifySql.add("update #tmptable c set c.errorMsg = CONCAT(ifnull(errorMsg,''),',','存在相同email号') \n" +
                "where exists(select 1 from (select a.id from #tmptable a,t_manager_user b where a.col1 = b" +
                ".`email` ) aa where aa.id = c.id) ");
        verifySql.add("update #tmptable c set c.errorMsg = CONCAT(ifnull(errorMsg,''),',','存在相同手机号') \n" +
                "where exists(select 1 from (select a.id from #tmptable a,t_manager_user b where a.col2 = b" +
                ".`mobile` ) aa where aa.id = c.id) ");
        verifySql.add("update #tmptable a inner join #tmptable b on b.col2 = a.col2 and a.id <> b.id \n" +
                "set a.errorMsg = CONCAT(ifnull(a.errorMsg,''),',','当前列表数据中存在相同手机号') where 1=1 ");
        verifySql.add("update #tmptable a inner join #tmptable b on b.col1 = a.col1 and a.id <> b.id \n" +
                " set a.errorMsg = CONCAT(ifnull(a.errorMsg,''),',','当前列表数据中存在相同email号') where 1=1 ");

        /**
         * 插入sql语句
         */
        List<String> insertSql = new ArrayList<>();
        insertSql.add("insert into t_manager_user(id,name,email,mobile,bir,addr)select a.id,a.col0,a.col1,a.col2,a.col3,a.col4 from #tmptable a");

        return this.importFile(fileDir, importTable, verifySql, insertSql, verifyList, baseBean, new ExcelUtils
                .ImportTableExecuteInterface() {

            String insertRoleSql = "";
            String insertOrgSql = "";

            /**
             * 在插入数据之前进行角色与组织名称
             *
             * @param tableName
             * @param list
             */
            @Override
            public void previous(String tableName, List<Map<String, Object>> list) {

                String sql = "select * from "+tableName;
                List<Map<String,Object>> tmpList = userReq.getTmpList(sql);

                List<Map<String,Object>> rolesList = new ArrayList<>();
                List<Map<String,Object>> orgsList = new ArrayList<>();


                //查询出所有角色信息
                List<Map<String,Object>> roleList = userReq.getRoleList();

                OrgBean orgBean = new OrgBean();
                orgBean.setPageNum(null);
                orgBean.setPageSize(null);
                List<Map<String,Object>> orgList = orgReq.getOrgList(orgBean);

                int cnt = tmpList.size();
                for(int i=0;i<cnt;i++){
                    String[] roles = StringHelper.get(tmpList.get(i),"col5").split(",");
                    String[] orgs = StringHelper.get(tmpList.get(i),"col6").split(",");
                    String id = StringHelper.get(tmpList.get(i),"id");

                    //检查角色是否在系统中存在
                    for(int j=0;j<roles.length;j++){
                        String role_name = roles[j];
                        if(!StringUtils.isBlank(role_name)){
                            String role_id = getRoleId(role_name,roleList);
                            if(!StringUtils.isBlank(role_id)){
                                Map<String,Object> map = new HashMap<>();
                                map.put("role_id",role_id);
                                map.put("user_id",id);
                                rolesList.add(map);
                            }else {
                                //没有值跟下到
                                if(userReq.update("update "+tableName+" set errorMsg=CONCAT(ifnull(errorMsg,''),',','角色【"+role_name+"】不存在') where id = "+id) <= 0){
                                    returnMap.setReturnMaps(ReturnMap.States.ERROR);
                                    returnMap.setMsgMaps("数据操作异常");
                                    return;
                                }
                            }
                        }
                    }

                    for(int j=0;j<orgs.length;j++){
                        String org_name = orgs[j];
                        if(!StringUtils.isBlank(org_name)){
                            String org_id = getOrgId(org_name,orgList);
                            if(!StringUtils.isBlank(org_id)){
                                Map<String,Object> map = new HashMap<>();
                                map.put("org_id",org_id);
                                map.put("user_id",id);
                                orgsList.add(map);
                            }else {
                                //没有值跟下到
                                if(userReq.update("update "+tableName+" set errorMsg=CONCAT(ifnull(errorMsg,''),',','组织【"+org_name+"】不存在') where id = "+id ) <= 0){
                                    returnMap.setReturnMaps(ReturnMap.States.ERROR);
                                    returnMap.setMsgMaps("数据操作异常");
                                    return;
                                }
                            }
                        }
                    }
                }

                logger.debug("rolesList:"+rolesList);
                logger.debug("orgsList:"+orgsList);

                if(!rolesList.isEmpty()){
                    insertRoleSql = "insert into t_manager_user_role(manager_role_id,manager_user_id)values";
                    int cnt_ = rolesList.size();
                    for(int i=0;i<cnt_;i++){
                        String roleId = StringHelper.get(rolesList.get(i),"role_id");
                        String userId = StringHelper.get(rolesList.get(i),"user_id");
                        insertRoleSql += "("+roleId+","+userId+")";
                        if(i != cnt_  - 1){
                            insertRoleSql += ",";
                        }
                    }

                }

                if(!orgsList.isEmpty()){
                    insertOrgSql = "insert into t_manager_user_org(manager_org_id,manager_user_id)values";
                    int cnt_ = orgsList.size();
                    for(int i=0;i<cnt_;i++){
                        String orgId = StringHelper.get(orgsList.get(i),"org_id");
                        String userId = StringHelper.get(orgsList.get(i),"user_id");
                        insertOrgSql += "("+orgId+","+userId+")";
                        if(i != cnt_  - 1){
                            insertOrgSql += ",";
                        }
                    }
                }


            }

            public String getRoleId(String role_name,List<Map<String,Object>> roleList){

                for(int i=0;i<roleList.size();i++){
                    String roleName = StringHelper.get(roleList.get(i),"role_name");
                    if(roleName.equals(role_name)){
                        return StringHelper.get(roleList.get(i),"id");
                    }
                }

                return "";
            }

            public String getOrgId(String org_name,List<Map<String,Object>> orgList){

                for(int i=0;i<orgList.size();i++){
                    String orgName = StringHelper.get(orgList.get(i),"org_name");
                    if(orgName.equals(org_name)){
                        return StringHelper.get(orgList.get(i),"id");
                    }
                }

                return "";
            }

            @Override
            public void upper(String tableName, List<Map<String, Object>> list) {
                if(StringUtils.isNotBlank(insertRoleSql)){
                    Integer exc = userReq.insert(insertRoleSql);
                    if(exc ==null && exc <= 0){
                        returnMap.setReturnMaps(ReturnMap.States.ERROR);
                        returnMap.setMsgMaps("数据操作异常");
                        return;
                    }
                }
                if(StringUtils.isNotBlank(insertOrgSql)){

                    if(userReq.insert(insertOrgSql) <= 0){
                        returnMap.setReturnMaps(ReturnMap.States.ERROR);
                        returnMap.setMsgMaps("数据操作异常");
                        return;
                    }
                }
            }
        });
    }

    /**
     * 修改密码
     * @param request
     * @param response
     * @return
     */
    public ReturnMap changePassword(HttpServletRequest request, HttpServletResponse response, UserBean userBean) {

        Map<String,Object> map = userUtil.getBackgroundUser();

        logger.debug("map:"+map);
        userBean.setMobile(StringHelper.get(map,"mobile"));
        userBean.setId(StringHelper.get(map,"id"));

        try {
            userBean.setPassword(XyBizMsgCrypt.MD5(userBean.getPassword()));
        } catch (Exception e) {
            logger.error("密码加密错误:",e);
            return returnMap.getErrorReturnMap("出现未知错误，请稍后再试");
        }

        Integer state = userReq.getUserState(userBean);

        if(state == null){
            return returnMap.getErrorReturnMap("原始密码输入错误");
        }

        if(state == 1){//密码输入正确

            if(!validator.isPassword(userBean.getPassword_new1())){
                return returnMap.getErrorReturnMap("新密码的组成至少要包括大小写字母、数字及标点符号的其中两项，且需要是8-30位有效数字");
            }

            if(!userBean.getPassword_new1().equals(userBean.getPassword_new2())){
                return returnMap.getErrorReturnMap("两次密码输入不一致");
            }

            try {
                userBean.setPassword(XyBizMsgCrypt.MD5(userBean.getPassword_new1()));
            } catch (Exception e) {
                logger.error("密码加密错误:",e);
                return returnMap.getErrorReturnMap("出现未知错误，请稍后再试");
            }

            Integer integer = userReq.resetPassword(userBean);
            if(integer == null || integer < 1){
                return returnMap.getErrorReturnMap("出现未知错误，请稍后再试");
            }
            return returnMap.getSucceeReturnMaps("密码修改成功,请重新登录系统。");
        }else{
            return returnMap.getErrorReturnMap("原始密码输入错误");
        }


    }
}
